﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Elev.CommonControl
{
    /// <summary>
    /// FolderBrowserDialogEX.xaml 的交互逻辑
    /// </summary>
    public partial class FolderBrowserDialogEX : UserControl
    {
        public event EventHandler<string> Click;

        private void OnSelected(object sender, string selectFilePath)
        {
            EventHandler<string> SelectedHandle = Click;
            if (SelectedHandle != null)
            {
                SelectedHandle(sender, selectFilePath);
            }
        }

        public string Text { get; set; }

        public FolderBrowserDialogEX()
        {
            InitializeComponent();
        }

        private void btnOpenDic_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            fbd.Description = "选择文件夹";
            fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
            //fbd.SelectedPath = projectPath;
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Text = fbd.SelectedPath;
                txbDicPath.Text = Text;
                OnSelected(fbd, Text);
            }
        }
    }
}
